/**
 * 返回原函数，但其只可执行一次
 * @param f
 */
export function Once<P extends unknown[], R>(f: (...args: P) => R) {
    let done = false;
    let returnValue: R;
    return (...args: P) => {
        if (!done) {
            done = true;
            return (returnValue = f(...args));
        }
        return returnValue;
    };
}
